! function(m, $) {
	var vm = new Vue({
		el: '#main',
		data: {
			dataObj: '',
			id: '',
			content: '',
			issuedepartment: '',
			path: rutour.notice.views,
			filelist: '',
			title: '',
			message: '',
			osspath: '',
			content: '',
			refresh: ''
		},
		mounted: function() {
			this.init();
		},
		methods: {
			init: function() {
				mui.plusReady(function() {
					var currentView = plus.webview.currentWebview(); // 获取 当前webview
					currentView.show('slide-in-right', 300); // 显示当前webview (方式,时间)
					plus.nativeUI.closeWaiting(); // 关闭系统 loading 等待
					var current = plus.webview.currentWebview();
					vm.id = current.newsid;
					token = plus.storage.getItem('token');
					mui.ajax(rutour.notice.views + token, {
						dataType: 'json',
						type: 'get',
						data: {
							id: vm.id
						},
						success: function(data) {
							if(data.code == 200) {
								vm.dataObj = data.data;
								vm.content = data.data.object.content;
								vm.refresh = data.data.object.content;
								vm.filelist = data.data.filelist;
								vm.title = vm.dataObj.object.title;
								vm.osspath = data.data.osspath;
								
							} else {
								mui.toast(data.msg)
							};
						}
					})
				});
				
			},
			optionImg: function(src) {
				var suffix = src.slice(src.lastIndexOf('.') + 1),
					suffix = suffix.toLowerCase();
				return 'images/' + suffix + '.png'
			},
			optionHref: function(href) {
				var isSupportDownload = 'download' in document.createElement('a');
				if(isSupportDownload) {
					return vm.osspath + href
				}
			},
			openSle: function() {
				$('.mui-title-icon').css({
					'opacity': '0',
					'display': 'none'
				});
				$(".mui-search").css("display", 'block').animate({
					width: '246px'
				}, 100);
				$('.mui-input-clear').focus();
			},
			closeSle: function() {
				$(".mui-search").animate({
					width: '0'
				}, 100).css("display", 'none');
				$('.mui-title-icon').css({
					'opacity': '1',
					'display': 'block'
				});
			},
			inputCha: function() {
				var val = vm.message,
					keyWordReg = new RegExp("([\s\S]*)" + val + "([a-z.]*)([\s\S]*)", "gmi");
				vm.content = vm.refresh;
				if(val !== '') {
					vm.content = vm.content.replace(keyWordReg, '<span style="color:red">$&</span>')
				}
			},
			optionDow:function(name){
				var suffix = name.slice(0,name.lastIndexOf('.'));
				return suffix
			},
			download: function(href) {
				var isSupportDownload = 'download' in document.createElement('a');
				m.plusReady(function() {
					if(!isSupportDownload) {
						var dtask = plus.downloader.createDownload(vm.osspath + href, {}, function(d, status) {
							// 下载完成
							if(status == 200) {
								m.toast("下载成功 ", {
									duration: 'long',
									type: 'div'
								});
							} else {
								m.toast("下载成功 失败！", {
									duration: 'long',
									type: 'div'
								});
							}
						});
						dtask.addEventListener("statechanged", onStateChanged, false);
						dtask.start();
					}

					function onStateChanged(download, status) {
						if(download.state == 4 && status == 200) {
							// 下载完成 
							m.confirm('查看文件?', '提示', ['取消', '查看'], function(e) {
								if(e.index == 1) {
									plus.runtime.openFile(download.getFileName(), function() {
										m.alert('打开文件失败')
									})
								}
							})
						}
					}
				})

			}
		}
	});
}(mui, jQuery)